package com.qcby.llmtchstd.controller;

import com.qcby.llmtchstd.common.ResponseResult;
import com.qcby.llmtchstd.entity.Exam;
import com.qcby.llmtchstd.entity.Note;
import com.qcby.llmtchstd.service.ExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/exam")  // 类级别路径映射
@Api(tags = "考试管理" )
public class ExamController {
    @Autowired
    private ExamService examService;
    @PostMapping("/add")
    public ResponseResult<Integer> addExam(@RequestBody Exam exam){
        Integer ans = examService.addExam(exam);
        if(ans != 0){
            return ResponseResult.success("保存成功",ans);
        }else {
            return ResponseResult.fail("5001","保存失败，请重试");
        }
    }

    @RequestMapping(value = "/count",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取数量" )
    public ResponseResult count(){
        return examService.count();
    }

    @RequestMapping(value = "/page",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("显示考试信息" )
    public ResponseResult page(@RequestBody Exam exam){
        return examService.page(exam);
    }

    @RequestMapping(value = "/search",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("查询考试信息" )
    public ResponseResult search(@RequestBody Exam exam){
        return examService.search(exam);
    }

    @RequestMapping(value = "/serCount",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("查询考试信息" )
    public ResponseResult serCount(@RequestBody Exam exam){
        return examService.serCount(exam);
    }


    @RequestMapping(value = "/generate",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("更新试卷")
    public ResponseResult generate(@RequestBody Exam exam){
        return examService.generate(exam);
    }

    @RequestMapping(value = "/generateAll",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("插入试卷" )
    public ResponseResult generateAll(@RequestBody Exam exam){
        return examService.generateAll(exam);
    }

    @RequestMapping(value = "/publish",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("发布考试")
    public ResponseResult publish(@RequestBody Exam exam){
        return examService.publish(exam);
    }

    @RequestMapping(value = "/generateAlll",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("插入试卷" )
    public ResponseResult generateAlll(@RequestBody Exam exam){
        return examService.generateAlll(exam);
    }

}
